<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>编辑机构 - Powered By Betou</title>
<meta name="author" content="Betou Team" />
<meta name="copyright" content="Betou" />
<#include "../head.html"/>
<link href="${base}/thirdparty/swfupload2_5/swf.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">var _BASE="${base}/";</script>
<script type="text/javascript" src="${base}/thirdparty/swfupload2_5/swfupload.js" charset="utf-8"></script>
<script type="text/javascript" src="${base}/thirdparty/swfupload2_5/fileprogress.js" charset="utf-8"></script>
<script type="text/javascript" src="${base}/thirdparty/swfupload2_5/handlers_logo.js" charset="utf-8"></script>
<link href="${base}/thirdparty/ztree/css/core.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${base}/thirdparty/ztree/js/core.js"></script>

<script type="text/javascript">
var roles = [<#list bean.roles as p>"${p.id!}"<#if p_has_next>,</#if></#list>];
$().ready(function() {

	var $browserAgency = $("input.browserAgency");
	var $browserAccount = $('input.browserAccount');
	
	var $inputForm = $("#inputForm");
	
	// 表单验证
	$inputForm.validate({
		rules: {
			mobile: { required: true,digits:true, minlength:11, remote:{
				url:"../v_check_mobile.jspx",
				oldValue:"${bean.mobile!}",
				cache:false
			} },
			email: {required: true,email:true, maxlength:100,remote:{
				url:"../v_check_email.jspx",
				oldValue:"${bean.email!!}",
				cache:false
			}},
			contract:{required: true},
			address:{required: true},
			tel:{required: true},
			qqService:{required: true,digits:true, minlength:5},
			password: {
				pattern: /^[^\s&\"<>]+$/,
				minlength: 4,
				maxlength: 20
			},
			rePassword: {
				equalTo: "#password"
			},
			intermediaName: {
				required:true,
				remote: {
					url: "../v_check_name.jspx",
					oldValue:"${bean.intermediaName!}",
					cache: false
				}
			},
			accountFunds: {
				min: 0,
				decimal: {
					integer: 12,
					fraction: 2
				}
			},
			
		},
		messages: {
			intermediaName:{
				remote:"已存在"
			},
			mobile:{
				remote:"已存在"
			},
			email:{
				remote:"已存在"
			}
		}
		
	});
	
});

deleteImg = function(id){
	$.dialog({
		type: "warn",
		content: message("admin.dialog.deleteConfirm"),
		ok: message("admin.dialog.ok"),
		cancel: message("admin.dialog.cancel"),
		onOk: function() {
			$.ajax({
				url: "o_delete_img.jspx" ,
				type: "POST",
				data: {"id":id},
				cache: false,
				success: function(message) {
					// 删除的动作主要是AJAX, 主要的问题就是数据被引用不能删除
					if( typeof(message) == 'string' ){
						var msg;
						if( message.indexOf("integrityViolation") != -1 ){
							msg = "数据被引用，不能删除！";
						}else{
							msg = "系统繁忙，请稍后重试！"
						}
						message = {type:"error", content: msg };
					}
					$.message(message);
					if (message.type == "success") {
							$('#id_' + id).remove();
							$('#path_' + id).remove();
							$('#container_' + id).remove();
					}
				},
				error:function(xmlHttpRequest, message, e){
					$.message( "error", e );
				}
			});
		}
	});
	
}

</script>
</head>
<body class="content">
	<div class="path">
		<a href="../index.jspx">首页</a> &raquo; 编辑机构
	</div>
	<form id="inputForm" action="o_update.jspx" method="post"  >
		<input type="hidden" id="disabled"  name="disabled" value="false"  />
		<input type="hidden" name="id" value="${bean.id!}"/>
		<table class="input tabContent">
			<tr>
				<th><h3>基本资料：</h3></th>
				<td colspan="3">&nbsp;</td>
			</tr>
			<tr>
				<th><span class="requiredField">*</span>机构名称:</th>
				<td>
					<input type="text" name="intermediaName" class="text" maxlength="100"  value="${bean.intermediaName!}" title="公司请填写公司名称，个人可以填写个人名称" />
				</td>
				<th>登录名:</th>
				<td>
					${bean.username!}
				</td>
			</tr>
			<tr>
				<th>密码:</th>
				<td>
					<input type="password" name="password"  id="password" class="text" maxlength="100"  />
				</td>
				<th>确认密码:</th>
				<td>
					<input type="password" name="rePassword"  class="text" maxlength="100"  />
				</td>
			</tr>
			<tr>
				<th><span class="requiredField">*</span>Email:</th>
				<td>
					<input type="text" name="email" class="text" maxlength="100"  value="${bean.email!}" />
				</td>
				<th><span class="requiredField">*</span>手机号码:</th>
				<td>
					<input type="text" name="mobile" class="text" maxlength="11"  value="${bean.mobile!}"/>
				</td>
			</tr>
			<tr>
				<th><span class="requiredField">*</span>联系人:</th>
				<td>
						<input type="text" name="contract" class="text" maxlength="30"  value="${bean.ext.contract!}" />
				</td>
				<th><span class="requiredField">*</span>联系地址:</th>
				<td>
						<input type="text" name="address" class="text" maxlength="100"  value="${bean.ext.address!}" />
				</td>
			</tr>
			<tr>
				<th><span class="requiredField">*</span>联系电话:</th>
				<td>
						<input type="text" name="tel" class="text" maxlength="100"  value="${bean.ext.tel!}"/>
				</td>
				<th><span class="requiredField">*</span>联系QQ:</th>
				<td>
						<input type="text" name="qqService" class="text" maxlength="15"  value="${bean.ext.qqService!}"/>
				</td>
			</tr>
			<tr>
				<th>推荐机构:</th>
				<td>
					<span>${(bean.ext.recommentAgent)!}</span>
				</td>
				<th>推荐账号:</th>
				<td>
					<span>${(bean.ext.recommentAccount)!}</span>
				</td>
			</tr>
			<tr>
				<th>角色</th>
				<td colspan="3">
					<span><#if bean.roles??><#list bean.roles as r>
							${r.name!}
					</#list></#if></span>
				</td>
			</tr>
		</table>
		<table class="input tabContent">
			<tr><th><h3>高级资料：</h3></th><td colspan="3">&nbsp;</td></tr>
			<tr>
				<th>企业名称:</th>
				<td>
						<input type="text" name="enterpriseName" class="text" maxlength="100"  value="${bean.ext.enterpriseName!}" />
				</td>
				<th>证件名称:</th>
				<td>
						<input type="text" name="documentName" class="text" maxlength="100"  value="${bean.ext.documentName!}" />
				</td>
			</tr>
			<tr>
				<th>证件号码:</th>
				<td>
						<input type="text" name="documentNum" class="text" maxlength="100"  value="${bean.ext.documentNum!}" />
				</td>
				<th>证件类型:</th>
				<td>
						<input type="text" name="documentType" class="text" maxlength="100"  value="${bean.ext.documentType!}" />
				</td>
			</tr>
			<tr>
				<th>营业执照:</th>
				<td>
						<input type="text" name="businessLicense" class="text" maxlength="100"  value="${bean.ext.businessLicense!}"  />
				</td>
				<th>税务登记号:</th>
				<td>
						<input type="text" name="taxRegistrationNumber" class="text" maxlength="100"  value="${bean.ext.taxRegistrationNumber!}"  />
				</td>
			</tr>
			<tr>
				<th>组织机构代码证:</th>
				<td>
						<input type="text" name="organizationCodeCertificate" class="text" maxlength="100"  value="${bean.ext.organizationCodeCertificate!}" />
				</td>
				<th>结算银行:</th>
				<td>
						<input type="text" name="bis" class="text" maxlength="100"  value="${bean.ext.bis!}" />
				</td>
			</tr>
			<tr>
				<th>法定代表人:</th>
				<td>
						<input type="text" name="legalRepresentative" class="text" maxlength="100"  value="${bean.ext.legalRepresentative!}" />
				</td>
				<th>开户名称:</th>
				<td>
						<input type="text" name="accountName" class="text" maxlength="100"  value="${bean.ext.accountName!}" />
				</td>
			</tr>
			<tr>
				<th>交易商编码开始:</th>
				<td>
						<input type="text" name="tradersCodingBegins" class="text" maxlength="100"  value="${bean.ext.tradersCodingBegins!}" />
				</td>
				<th>交易商编码结束:</th>
				<td>
						<input type="text" name="tradersCodingEnds" class="text" maxlength="100"  value="${bean.ext.tradersCodingEnds!}" />
				</td>
			</tr>
			<tr>
				<th>银行帐号:</th>
				<td>
						<input type="text" name="bankAccount" class="text" maxlength="100"  value="${bean.ext.bankAccount!}" />
				</td>
				<th>账户资金:</th>
				<td>
						<input type="text" name="accountFunds" class="text" maxlength="100"  value="${bean.ext.accountFunds!}" />
				</td>
			</tr>
			<tr>
				<th>备注说明:</th>
				<td colspan="3">
					<textarea name="intro" style="width:400px;height:100px">${bean.ext.intro!} </textarea>
				</td>
			</tr>
		</table>
		<table class="input">
			<tr>
				<th>证件扫描：</th>
				<td>
					
					<div id='fsUploadProgress' class='clearfix'>
					<#list bean.pics as p>
						<input type="hidden" name="picIds" value="${p.id!}" id="id_${p.id!}"/>	
						<input type="hidden" name="pic" value="${p.path!}" id="path_${p.id!}"/>
						<div class="progressContainer blue" style="float:left" id="container_${p.id!}">
							<div class="progressName">${p.shortPath!}</div>
							<div class="progressBarStatus"><a href="javascript:;"  onclick="deleteImg(${p.id!})">删除</a></div>
							<div class="viewDiv" >
								<a href="${base}/${p.path!}"  title="查看大图" target="_blank"><img src="${base}/${p.path!}"/></a>
							</div>	
						</div>			
					</#list>
					</div>
					<input type="button" id="uploadBtn" value="选择文件"  class="button"/>
				</td>
			</tr>
		</table>
		<table class="input">
			<tr>
				<th>&nbsp;</th>
				<td>
					<input type="submit" class="button" value="确&nbsp;&nbsp;定" />
					<input type="button" class="button" value="返&nbsp;&nbsp;回" onclick="location.href='v_list.jspx'" />
				</td>
			</tr>
		</table>
	</form>
	<#include "../footer.html"/>
</body>
</html>

<script type='text/javascript'>
var swfu;
var jsessionid = getCookie("JSESSIONID");
var uploadUrl='/all_upload.jhtml';
if(jsessionid) {
	uploadUrl += ";jsessionid="+jsessionid;
}
var settings = {
	post_params: {"directory": "upload"},
	flash_url:"${base}/thirdparty/swfupload2_5/swfupload.swf", 
	flash9_url:"${base}/thirdparty/swfupload2_5/swfupload_fp9.swf", 
	upload_url: uploadUrl,  
	file_size_limit:"1MB", 
	file_types:"*.jpg;*.png;*.gif;*.jpeg", 
	file_types_description:"JPG Images; PNG Image", 
	file_upload_limit:10, 
	file_queue_limit:0, 
	custom_settings:{progressTarget:"fsUploadProgress", cancelButtonId:"btnCancel"}, 
	button_image_url:"${base}/thirdparty/swfupload2_5/choose_file.jpg", 
	button_placeholder_id:"uploadBtn", 
	button_width:175, 
	button_height:52, 
	button_text_top_padding:0, 
	button_window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT, 
	button_cursor:SWFUpload.CURSOR.HAND, 
	swfupload_preload_handler:preLoad, 
	swfupload_load_failed_handler:loadFailed, 
	file_queued_handler:fileQueued, 
	file_queue_error_handler:fileQueueError, 
	upload_start_handler:uploadStart, 
	upload_progress_handler:uploadProgress, 
	upload_error_handler:uploadError, 
	upload_success_handler:uploadSuccess, 
	upload_complete_handler:uploadComplete
};

swfu = new SWFUpload(settings);
$(document).ready(function(){
	if( !swfu.support.loading ){
		$('#fsUploadProgress').html('您当前的Flash Player版本过低,无法支持头像上传,点击<a href="http://get.adobe.com/cn/flashplayer/otherversions/" target="_blank">下载</a>');
	}
})
</script>
